<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class ChangeAddColumnScopeInPlanTable extends AbstractMigration
{

    public function up()
    {
        $this->table('plan')
            ->addColumn('scope', 'enum', ['values' => 'single,global', 'default' => 'single', 'comment' => '范围 (single 单集,global 全局)'])
            ->changeColumn('type', 'enum', ['values' => 'episode,step_category,entity,entity_step_category,to_do,milestone,meeting,review,custom', 'default' => 'step_category', 'comment' => '类型 episode 集,step_category 工序分类任务，entity 实体,entity_step_category 实体工序分类,todo 代办,milestone 里程碑,meeting 会议,review 审核,custom 自定义'])
            ->addIndex(['task_id'], ['type' => 'normal', 'name' => 'idx_task_id'])
            ->save();
    }

    public function down()
    {
        $this->table('note')
            ->changeColumn('type', 'enum', ['values' => 'episode,step_category,entity,entity_step_category,to_do,', 'default' => 'step_category', 'comment' => '类型 episode 集,step_category 工序分类任务，entity 实体,entity_step_category 实体工序分类,todo 代办'])
            ->removeColumn('scope')
            ->removeIndex('idx_task_id')
            ->save();
    }
}
